package com.mstanford.movie.utils;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;

public class SendHtmlEmail {

	public static void sendEmail(String toEmail, String htmlMsg) {

		HtmlEmail htmlEmail = new HtmlEmail();

		htmlEmail.setCharset("UTF-8");
		htmlEmail.setHostName("smtp.sina.com");
		htmlEmail.setSmtpPort(25);
		htmlEmail.setAuthentication("haifengemail@sina.com", "haifeng");
		htmlEmail.setTLS(true);

		try {
			htmlEmail.addTo(toEmail);
			htmlEmail.setFrom("tianrenemail@sina.com");
			htmlEmail.setSubject("海峰电影");

			htmlEmail.setHtmlMsg("<html>" + htmlMsg + "</html>");

			htmlEmail.send();
		} catch (EmailException e) {
			e.printStackTrace();
		}
	}
}